package co.example.michael.broadcastreceivertest;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.widget.Toast;

/**
 * Created by Michael on 2015/3/23.
 */
public class StaticReceiverTest extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        if (intent.getAction().equals("static")){
            String msg = intent.getStringExtra("msg");
            Toast.makeText(context,msg,Toast.LENGTH_LONG).show();

            NotificationManager notificationManager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);

            Notification notification = new Notification(R.drawable.ic_launcher,"title",System.currentTimeMillis());
            Intent intent1 = new Intent(context,NotificationActivity.class);
            PendingIntent pendingIntent = PendingIntent.getActivity(context,0,intent1,PendingIntent.FLAG_CANCEL_CURRENT);
            notification.defaults = Notification.DEFAULT_ALL;
            notification.ledARGB = Color.GREEN;
            notification.ledOnMS = 1000;
            notification.ledOffMS = 1000;
            notification.flags = Notification.FLAG_SHOW_LIGHTS;
            notification.setLatestEventInfo(context,"title2","content",pendingIntent);
            notificationManager.notify(1,notification);

        }


    }
}
